package com.azunitech.apm.bundles.http;

import javax.servlet.ServletException;

import org.osgi.service.http.HttpService;
import org.osgi.service.http.NamespaceException;
import org.osgi.service.log.LogService;

public class DataGenerator {
    private volatile Store m_store;
    private volatile LogService m_log;
    private volatile HttpService m_HttpService;
    
    public void generate() {
        for (int i = 0; i < 10; i++) {
            m_store.put("#" + i, "value_" + i);
        }
        m_log.log(LogService.LOG_INFO, "Data generated.");
        
        
    }
    
    public void added( Store ss ) throws ServletException, NamespaceException  {
    	m_HttpService.registerServlet("/test", new MyTestServlet(), null, null);
		m_log.log(LogService.LOG_INFO, "&&&&&&&&&&&&&&&&&&&&&&&&&&& Http Injected.");
		System.out.println("$$$$$$$$$$$$$$$$$$$$$$ added $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
    }
    
    public void removed() {
    	m_HttpService.unregister("/test");
		m_log.log(LogService.LOG_INFO, "&&&&&&&&&&&&&&&&&&&&&&&&&&& Http UnInjected.");
		System.out.println("$$$$$$$$$$$$$$$$$$$$$$$ removed $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
    }
}
